import Vue from 'vue'
import axios from 'axios'
import apiList from './apiList'

const instance = axios.create({
  baseURL: '',
  timeout: 1000,
  headers: {
    "Content-Type": "application/json",
    'Accept': 'application/json'
  }
})

// 添加响应拦截器
instance.interceptors.response.use(function (response) {
  // 对响应数据做点什么
  return response.data
}, function (error) {
  // 处理错误信息
  // location.href = '/'

  // 对响应错误做点什么
  return Promise.reject(error);
})

export default {

  get(key, params) {
    const url = apiList[key]
    return instance.get(url, {
      params
    })
  },

  post() {

  }
}